package com.ctvit.cch.web.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ctvit.cch.core.pojo.dto.hot.HotCategoryFavoriteAddDTO;
import com.ctvit.cch.core.pojo.dto.hot.HotCategoryFavoriteBatchAddDTO;
import com.ctvit.cch.core.service.IHotCategoryFavoriteService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Arrays;

/**
 * 热点分类收藏Controller
 *
 * @author heyingcheng
 * @date 2025/11/07
 */
@RestController
@RequestMapping("/hot/category/favorite")
public class HotCategoryFavoriteController extends BaseController {

    private final IHotCategoryFavoriteService hotCategoryFavoriteService;

    public HotCategoryFavoriteController(IHotCategoryFavoriteService hotCategoryFavoriteService) {
        this.hotCategoryFavoriteService = hotCategoryFavoriteService;
    }

    /**
     * 新增热点分类收藏
     */
    @Log(title = "热点分类收藏", businessType = BusinessType.INSERT)
    @PreAuthorize("@ss.hasPermi('hot:category:favorite:add')")
    @PostMapping
    public AjaxResult add(@RequestBody HotCategoryFavoriteAddDTO dto) {
        return toAjax(hotCategoryFavoriteService.add(dto));
    }
    
    /**
     * 批量新增热点分类收藏
     */
    @Log(title = "热点分类收藏", businessType = BusinessType.INSERT)
    @PreAuthorize("@ss.hasPermi('hot:category:favorite:add')")
    @PostMapping("/batch/add")
    public AjaxResult batchAdd(@RequestBody HotCategoryFavoriteBatchAddDTO dto) {
        return toAjax(hotCategoryFavoriteService.batchAdd(dto));
    }

    /**
     * 删除热点分类收藏
     */
    @PreAuthorize("@ss.hasPermi('hot:category:favorite:remove')")
    @Log(title = "热点分类收藏", businessType = BusinessType.DELETE)
    @DeleteMapping("/remove")
    public AjaxResult remove(@RequestBody Long[] ids) {
        return toAjax(hotCategoryFavoriteService.removeBatchByIds(Arrays.asList(ids)));
    }

}